package com.alpha.feign.common.entity;

import com.alpha.core.entity.AlphaEntity;
import com.alpha.core.utils.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 租户实体
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@Data
@Schema(name = "租户")
@Accessors(chain = true)
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class Tenant extends AlphaEntity {
    @NotNull(message = "租户名称不能为空")
    @Schema(description = "租户名称")
    private String name;

    @Schema(description = "联系人")
    private String contact;

    @Schema(description = "联系邮箱")
    private String email;

    @Schema(description = "联系电话")
    private String telephone;

    @NotNull(message = "状态不能为空")
    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    @Schema(description = "状态", defaultValue = "1")
    private Boolean enabled;

    @NotNull(message = "账户数上限不能为空")
    @Schema(description = "账户数上限")
    private Integer accountLimit;

    @NotNull(message = "有效期不能为空")
    @JsonFormat(pattern = DateUtil.NORM_DATE_PATTERN)
    @Schema(description = "有效期")
    private Date expirationDate;

    @SuppressWarnings("unused")
    public Tenant(String name, Boolean enabled, Integer accountLimit, Date expirationDate) {
        // NotNull fields
        this.name = name;
        this.enabled = enabled;
        this.accountLimit = accountLimit;
        this.expirationDate = expirationDate;
    }
}
